#include <cstdio>
#include <iostream>

using namespace std;

int c[35][35];
inline int calc(const int &n){
    int ans=0;
    for(int i=(n+1)>>1;i<n;i++) ans+=c[n-1][i];
    return ans;
}

inline int solve(const int &x){
    //printf("solving %d:\n",x);
    if(x<=1) return 0;
    int mask,bits,ans;
    int cnt1,cnt0;
    bits=31;mask=1<<30;
    while(!(x&mask)) bits--,mask>>=1;
    //printf("x=%d,mask=%d,bits=%d\n",x,mask,bits);
    ans=0;
    for(int i=1;i<bits;i++) ans+=calc(i)/*,printf("\tcalc(%d)=%d\n",i,calc(i))*/;
    cnt1=1;cnt0=0;
    for(mask>>=1,bits--;mask;mask>>=1,bits--){
        if(x&mask){
            for(int i=0;i<bits;i++){ //count of 0
                if(i+cnt0+1>=cnt1+(bits-1-i)) ans+=c[bits-1][i];
            }
            cnt1++;
        }else cnt0++;
    }
    //printf("solve(%d)=%d\n",x,ans);
    return ans;
}

int main(){
    int s,t;

    c[0][0]=1;
    for(int n=1;n<35;n++){
        c[n][0]=1;
        for(int m=1;m<n;m++) c[n][m]=c[n-1][m-1]+c[n-1][m];
        c[n][n]=1;
    }

    //for(int i=1;i<5;i++,putchar('\n')) for(int j=0;j<=i;j++) printf("c[%d][%d]=%d\t",i,j,c[i][j]);
    //while(cin>>t) solve(t);

    scanf("%d%d",&s,&t);
    printf("%d\n",solve(t+1)-solve(s));

    return 0;
}
